package net.pm.common.service.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import net.pm.common.dao.GenericDao;
import net.pm.common.service.GenericServicer;
import net.pm.common.toolkit.Pager;

/**公共的服务接口的实现
 * @author shizeyuan
 *
 * @param <T>
 * @param <ID>
 */
public abstract class GenericServicerImpl<T extends Serializable, ID extends Serializable>
		implements GenericServicer<T, ID> {

	protected GenericDao<T, ID> genericDao;
	
	public abstract void setGenericDao(GenericDao<T, ID> genericDao);

	@Override
	public ID create(T t) {
		return genericDao.create(t);
	}

	@Override
	public void batchCreate(Collection<T> ts) {
		genericDao.batchCreate(ts);
	}

	@Override
	public void remove(T t) {
		genericDao.remove(t);
	}

	@Override
	public void removeById(ID id) {
		genericDao.removeById(id);
	}

	@Override
	public Integer removeByJpql(StringBuilder jpql, Object... args) {
		return genericDao.removeByJpql(jpql, args);
	}

	@Override
	public void batchRemove(Collection<ID> ids) {
		genericDao.batchRemove(ids);		
	}

	@Override
	public void modify(T t) {
		genericDao.modify(t);
	}

	@Override
	public Integer modifyByJpql(StringBuilder jpql, Object... args) {
		return genericDao.modifyByJpql(jpql, args);
	}

	@Override
	public void batchModify(Collection<T> ts) {
		genericDao.batchModify(ts);
	}

	@Override
	public void createOrModify(T t) {
		genericDao.createOrModify(t);		
	}

	@Override
	public T loadEntityById(ID id) {
		return genericDao.loadEntityById(id);
	}

	@Override
	public T findEntityById(ID id) {
		return genericDao.findEntityById(id);
	}

	@Override
	public List<T> findEntitiesByJpql(StringBuilder jpql, Object... args) {
		return genericDao.findEntitiesByJpql(jpql, args);
	}

	@Override
	public T findUniqueEntityByJpql(StringBuilder jpql, Object... args) {
		return genericDao.findUniqueEntityByJpql(jpql, args);
	}

	@Override
	public Pager<T> findPagerByJpql(Integer pagesize, Integer pageno,
			StringBuilder jpql, Object... args) {
		return genericDao.findPagerByJpql(pagesize, pageno, jpql, args);
	}

	@Override
	public List<T> findAll() {
		return genericDao.findAll();
	}

	@Override
	public Long findCountAll() {
		return genericDao.findCountAll();
	}

	@Override
	public Long findCountByJpql(StringBuilder jpql, Object... args) {
		return genericDao.findCountByJpql(jpql, args);
	}

	@Override
	public List<?> CallProcedure(String procName) {
		return genericDao.CallProcedure(procName);
	}

	@Override
	public void commit() {
		genericDao.commit();
	}
	
	
}
